package com.zhouyu;

import com.zhouyu.mybatisSpring.ZhouyuImportBeanDefinitionRegistrar;
import com.zhouyu.mybatisSpring.ZhouyuMapperScan;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.annotation.*;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

@ComponentScan("com.zhouyu")
@ZhouyuMapperScan("com.zhouyu.mapper")
//@Import(ZhouyuImportBeanDefinitionRegistrar.class)   //将
public class AppConfig {


	@Bean
	public SqlSessionFactory sqlSessionFactory() throws IOException {
		InputStream inputStream = Resources.getResourceAsStream("mybatis.xml");
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
		return sqlSessionFactory;
	}
}

